package com.kewu.utils;

public class MemoryUnitFormatting {

    public static String getFormatting(int b) {
        int a[] = new int[5];
        String[] s={"B","Kb ","Mb ","Gb ","Tb "};
        int i=0;
        while(b>=1024){
            a[i]=b%1024;
            b/=1024;
            i++;
        }
        a[i]=b;
        String str="";
        for (int j=0;j<=i;j++){
            if(a[j]!=0){
                str=a[j]+s[j]+str;
            }
        }
        return str;
    }

  /*  public static void main(String[] args) {
        String formatting = MemoryUnitFormatting.getFormatting(1024*1024+1);
        System.out.println(formatting);
    }*/

}
